package com.magic.gre.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.magic.gre.R;
import com.magic.gre.base.activity.BaseMVPActivity;
import com.magic.gre.mvp.contract.SuggestionContract;
import com.magic.gre.mvp.presenter.SuggestionPresenterImpl;
import com.noname.lib_base_java.util.ToastUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Author: Lmoumou
 * Date: 2019-01-10 21:03
 * 文件名: SuggestionActvity
 * 描述:
 */
public class SuggestionActvity extends BaseMVPActivity<SuggestionPresenterImpl> implements SuggestionContract.View {

    @BindView(R.id.right_tv)
    TextView rightTv;
    @BindView(R.id.content_tv)
    EditText contentTv;
    @BindView(R.id.contract_tv)
    EditText contractTv;

    public static void startThis(Context context) {
        Intent intent = new Intent(context.getApplicationContext(), SuggestionActvity.class);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_suggestion;
    }

    @Override
    protected SuggestionPresenterImpl creatPresenter() {
        return new SuggestionPresenterImpl(this);
    }

    @Override
    protected void netOverride() {

    }

    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {
        super.initView(savedInstanceState);

    }

    @OnClick(value = {R.id.right_tv})
    protected void onClick(View view) {
        switch (view.getId()) {
            case R.id.right_tv:
                sumbitDta();
                break;
        }
    }

    private void sumbitDta() {
        String contentStr = String.valueOf(contentTv.getText());
        if (TextUtils.isEmpty(contentStr)) {
            ToastUtil.getInstance().showNormal(this, "请输入内容");
            return;
        }

        String contract = String.valueOf(contractTv.getText());
        if (TextUtils.isEmpty(contentStr)) {
            ToastUtil.getInstance().showNormal(this, "请输入联系方式");
            return;
        }

        mPresenter.pFeedBack(contentStr, contract);
    }

    @Override
    public void vFeedBack() {
        ToastUtil.getInstance().showNormal(this, "意见已提交");
        finish();
    }
}
